package com.yf1706.service;

import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.yf1706.bean.CheckAffairApply;
import com.yf1706.bean.CheckNotarizeAffair;
import com.yf1706.dao.jpa.ICheckAffairApplyJDAO;
import com.yf1706.dao.jpa.ICheckNotarizeAffairJDAO;
import com.yf1706.dao.mybatis.CheckNotarizeAffairMDAO;

@Service
@Transactional(rollbackFor=Exception.class)
public class CheckNotarizeAffairService {
	@Autowired
	private ICheckNotarizeAffairJDAO cnaJdao;
	@Autowired
	private CheckNotarizeAffairMDAO   cnaMdao;
	@Autowired 
	private ICheckAffairApplyJDAO caaJDao;
	public List<CheckNotarizeAffair> getNotarizeAffair(){
		return cnaMdao.queryCheckNotarizeAffair();
	}
	public void addCheckNotarizeAffai(CheckAffairApply aa,String url) {
		//事务确认中中存储事务申请
		aa.setFileDocuments(url);
		aa.setMakeTime(new Date());
		aa.setState("是");
		//存储事务申请
		caaJDao.save(aa);
		//存储事务审批
		CheckNotarizeAffair na=new CheckNotarizeAffair();
		na.setCheckAffairApply(aa);
		na.setAffairName(aa.getHolidayType());
		na.setBeginTime(aa.getBeginTime());
		na.setEndTime(aa.getEndTime());
		na.setApprovalStatus("未审核");
		na.setState("是");		
		//存储事务确认
		cnaJdao.save(na);
	}
	
	//模糊查询指定的事假申请信息
	public List<CheckNotarizeAffair> serchcheckNotarizeApply(String affairName){
		return cnaMdao.serchcheckNotarizeApply(affairName);
	}
	public void updateNotarizeApply(int id,String approvalStatus) {
		cnaMdao.updateNotarizeApply(id,approvalStatus);
	}
}
